package com.snfdf.camunda.externaltask;

import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.client.spring.annotation.ExternalTaskSubscription;
import org.camunda.bpm.client.task.ExternalTaskHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Optional;

@Slf4j
@Configuration
public class VideoCheckExternalTaskService {

    @Bean
    @ExternalTaskSubscription(topicName = "checkNegative", processDefinitionKeyIn = {"Process_parallel_gateway", "Process_embedded_subprocess", "Process_call_activity_subprocess"}, lockDuration = 50000)
    public ExternalTaskHandler checkVideoNegative() {
        return (externalTask, externalTaskService) -> {
            log.info("进入检查视频是否负面");
            // String videoName = Optional.ofNullable(externalTask.getVariable("videoName")).map(Object::toString).orElse("");
            String videoName = Optional.ofNullable(externalTask.getVariable("targetVideoName")).map(Object::toString).orElse("");
            log.info("视频名称：{}不包含负面内容", videoName);
            externalTaskService.complete(externalTask);
        };
    }
}
